<?php

 // 连接数据库
 $conn = mysqli_connect('b-y6vghyumfx2mec.bch.rds.gz.baidubce.com:3306' , 'b_y6vghyumfx2mec' , 'wza010826' , 'b_y6vghyumfx2mec') ;

 if(!$conn) {
    die('数据库连接失败') ;
}


$id = $_POST['id'] ;
$uname = $_POST['username'] ;

$res = [] ;
if($id){
    
        // 修改数量  update
        $sql = "DELETE FROM hwcart WHERE username ='$uname' AND goods_id= $id";
        $i = mysqli_query($conn , $sql) ;
        // 受影响的行数
        if($i > 0) {
            $res['status'] = true ;
            $res['msg'] = '删除成功' ;
        } else {
            $res['status'] = false ;
            $res['msg'] = '数据库错误' ;
        }
   
}
else {
    $res['status'] = false ;
    $res['msg'] = '前端数据有误' ;
}
echo(json_encode($res)) ;
